package org.robot.config;

import java.util.Random;
import java.util.stream.IntStream;

public class Config {
    private int timeout = 30000;
    private int interval = 1000;
    private String baseDirectory;
    private int threadNumber = Runtime.getRuntime().availableProcessors();
    /**保存在本地的文件的最小长度*/
    private int len = 1024;
    public int getTimeout() {
		return timeout;
	}
	public Config setTimeout(int timeout) {
		this.timeout = timeout;
		return this;
	}
	public int getInterval() {
		return new Random().nextInt(interval);
	}
	/**
	 * 默认最大提交任务间隔时间1000毫秒
	 * @author pdz
	 * @date 2019年1月14日
	 * @param interval
	 * @return
	 */
	public Config setInterval(int interval) {
		this.interval = interval;
		return this;
	}
	public String getBaseDirectory() {
		return baseDirectory;
	}
	public Config setBaseDirectory(String baseDirectory) {
		this.baseDirectory = baseDirectory;
		return this;
	}
	public int getThreadNumber() {
		return threadNumber;
	}
	public Config setThreadNumber(int threadNumber) {
		this.threadNumber = threadNumber;
		return this;
	}
	public int getLen() {
		return len;
	}
	public Config setLen(int len) {
		this.len = len;
		return this;
	}
	@Override
	public String toString() {
		return "Config [timeout=" + timeout + ", interval=" + interval + ", baseDirectory=" + baseDirectory
				+ ", threadNumber=" + threadNumber + "]";
	}
	
	public static void main(String[] args) {
    	Config config = new Config();
    	config.setInterval(1);
    	IntStream.range(0, 10).forEach(i -> {
			System.out.println(config.getInterval());
    	});
	}
}
